# 1. 安装一个科学与计算的框架
import numpy as np
from datas import datas
X=[]
Y=[]
cityMark={"吕梁":1,"太原":2}
for item in datas:
    single=[]
    #城市
    single.append(cityMark[item["city"]])
    #面积
    single.append(item["area"])
    #rooms
    single.append(item["rooms"])
    #school
    single.append(item["school"])
    #style
    single.append(item["style"])
    X.append(single)
    Y.append(item["price"])

X = np.array(X)
Y = np.array(Y)
theta = np.linalg.pinv(X.T.dot(X)).dot(X.T).dot(Y)
print(theta)

